// 1.2  We now wrap the whole thing in a self execution function emulating function such as jQuery
(function(){

  // 1.1  We first create a sample function that will be loaded from another file.
  function testerFunction (from) {
    console.log(from, " Loaded Tester Function");
  }
  // testerFunction("main");
  
  // 1.5  We will now want to save our function to a global variable
  var testerObject = {useMe: testerFunction};
  
  // 1.8  We will now try to return our object
  // return testerObject;
  
  // 1.9  We will now try to set a document.testerObject
  document.testerObject = testerObject;
})();
// 1.3  We will now check if the fuction available to the outside world
// console.log(typeof testerFunction); // 1.4  Result: undifiened

// 1.6  We now check if testerBject.useMe exists and is a function
// console.log(typeof testerObject); // 1.7 Result: undifiened

// 1.10 Try to see if the document.testerObject exists
// console.log(typeof document.testerObject); // 1.11  Result: object

// 1.12 Now we set the variable obj to document.testerObject and try to use the object's useMe function
obj = document.testerObject;
// obj.useMe("On the outside!"); // 1.13 Result: On the outside!  Loaded Tester Function

// 1.14 Lets try to save document.testerObject to the localStorage
// 1.15 localStorage['testerObject'] = document.testerObject;

// 1.16 Now lets try to access testerObject after it was saved to localStorage
// Note that localStorage was not set in this session as we commented the 
// setter for localStorage['testerObject'];
// 1.23 Commented out: newObj = localStorage['testerObject'];
// newObj.useMe('Way out west, this object was saved in the client side!'); // 1.17  Result: newObj is null

// 1.18 Lets check the type of newObj and dir it to the console
// console.log(typeof newObj); // 1.19 Result: object
// console.dir(newObj); // 1.20  Result: *nothing*
// console.log(newObj); // 1.21  Result: null
// console.log(typeof localStorage['testerObject']); // 1.22   Result: object
// 1.24 Commented out: console.log("localStorage['testerObject'] = ", localStorage['testerObject']); // 1.23 Result: null


// 1.25 Checking if localStorage works at all...
// 1.28 Commenting out: localStorage['testing'] = "Testing String set in local storage";

// 1.26 Checking if localStorage['testing'] equals to something while set in the current session
console.log("localStorage['testing']: ", localStorage['testing']); // 1.27 Result: localStorage['testing']:  Testing String set in local storage 
// 1.28 Checking if localStorage['testing'] exists after reloading the page and the set is in the previous session
// 1.29 Result: localStorage['testing']:  Testing String set in local storage

/* Conlusion
  It seems as the localStorage will store data as text, but not as objects.
  Now I'm going to check if we can save a function as a localStoarge variable
*/
  


